<template>
    <div class="layout">
        <div class="title">素材中心Top10</div>
        <div v-if="weChart == 1" class="btnList">
            <el-radio-group v-model="currentId">
                <el-radio-button label="1">浏览人数</el-radio-button>
                <el-radio-button label="2">浏览次数</el-radio-button>
                <el-radio-button label="3">浏览时长</el-radio-button>
                <el-radio-button label="4">员工分享人数</el-radio-button>
                <el-radio-button label="5">客户分享人数</el-radio-button>
            </el-radio-group>
        </div>
        <div v-else class="btnList">
            <el-radio-group v-model="currentIndex">
                <el-radio-button label="1">浏览人数</el-radio-button>
                <el-radio-button label="2">浏览次数</el-radio-button>
                <el-radio-button label="3">浏览时长</el-radio-button>
            </el-radio-group>
        </div>
        <div v-if="weChart == 1 && topContent.length > 0" class="dataList">
            <ul class="list">
                <li v-for="(item, index) in topContent" :key="index" class="list_item">
                    <div class="left">
                        <span :class="index > 2 ? 'top_item' : 'item_id'">{{ index + 1 }}</span>
                        <el-image :src="mapLogo(item)" />
                        <span class="item_title">{{ item.title || '--' }}</span>
                    </div>
                    <div class="right">
                        <div class="icon">
                            <img src="@/assets/login/visible.png" alt="" />
                        </div>
                        <div class="number">{{ item.data_num || '-' }}</div>
                    </div>
                </li>
            </ul>
        </div>
        <div v-if="weChart == 1 && topContent.length == 0" class="no_data">
            <img class="no_img" src="@/assets/noData.png" alt="" />
            <div class="no_title">暂无数据</div>
        </div>
        <div v-if="weChart != 1 && monmentTop.length > 0" class="dataList">
            <ul class="list">
                <li v-for="(item, index) in monmentTop" :key="index" class="list_item">
                    <div class="left">
                        <span :class="index > 2 ? 'top_item' : 'item_id'">{{ index + 1 }}</span>
                        <el-image :src="mapLogo(item)" />
                        <span class="item_title">{{ item.title || '--' }}</span>
                    </div>
                    <div class="right">
                        <div class="icon">
                            <img src="@/assets/login/visible.png" alt="" />
                        </div>
                        <div class="number">{{ item.data_num || '-' }}</div>
                    </div>
                </li>
            </ul>
        </div>
        <div v-if="weChart != 1 && monmentTop.length == 0" class="no_data">
            <img class="no_img" src="@/assets/noData.png" alt="" />
            <div class="no_title">暂无数据</div>
        </div>
    </div>
</template>

<script setup lang="ts">
import { ref, watch, onMounted } from 'vue';
import { materialTabs } from '@/utils/utils';

const currentId = ref(1); // 按钮切花 id
const currentIndex = ref(1);
const props = defineProps(['topContent', 'weChart', 'monmentTop']);
const emit = defineEmits({
    changeBtn: null,
    changeIndex: null
});

const mapLogo = (item: any) => {
    return materialTabs.find((ite: any) => ite.type == item.content_type)?.icon;
};

watch(currentIndex, v => {
    currentIndex.value = v;
    emit('changeIndex', v);
});
watch(currentId, v => {
    currentId.value = v;
    emit('changeBtn', v);
});

onMounted(() => {
    setTimeout(() => {}, 2000);
});
</script>

<style lang="scss" scoped>
ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.layout {
    background: #fff;
    border: 1px solid #eaeaea;

    .title {
        display: flex;
        align-items: center;
        height: 56px;
        padding: 0 24px;
        margin-bottom: 16px;
        font-size: 16px;
        border-bottom: 1px solid #eaeaea;
    }

    .btnList {
        display: flex;
        justify-content: space-between;
        padding: 0 24px;
        margin-top: 20px;

        .left_btn {
            display: flex;

            .btn_item {
                color: #ff6b00;
                font-size: 16px;
                padding: 10px 18px;
                border: 1px solid #ff6b00;
                background: #fff;
                cursor: pointer;
            }

            .active {
                background: #ff6b00;
                color: #fff;
            }
        }

        .right_btn {
            font-size: 14px;
            border: 1px solid #eaeaea;
            height: 36px;
            line-height: 36px;
            padding: 0 18px;
            cursor: pointer;
        }
    }

    .dataList {
        margin-top: 20px;
        padding: 0 24px 24px;
        font-size: 14px;
        color: #33302d;

        .list {
            &_item {
                display: flex;
                justify-content: space-between;
                align-items: center;
                border-bottom: 1px dashed #eaeaea;
                padding: 17px 17px 17px 20px;

                &:nth-child(2n) {
                    background-color: #f9f9f9;
                }

                .left {
                    display: flex;
                    align-items: center;

                    .el-image {
                        width: 28px;
                        height: 28px;
                        margin-right: 6px;
                    }

                    .item_id {
                        margin: 2px 14px 0 0;
                        color: #ff6b00;
                    }

                    .top_item {
                        margin: 2px 14px 0 0;
                        color: black;
                    }
                }

                .right {
                    display: flex;
                    align-items: center;

                    .icon {
                        width: 14px;
                        height: 10px;
                        margin-top: -5px;

                        img {
                            width: 100%;
                            height: 100%;
                        }
                    }

                    .number {
                        color: #969696;
                        font-size: 14px;
                        margin-left: 2px;
                    }
                }
            }
        }
    }

    .no_data {
        height: 500px;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;

        .no_img {
            margin-left: 24px;
        }

        .no_title {
            color: #909399;
            font-size: 14px;
        }
    }
}
</style>
